﻿namespace TestTool.GUI.Data
{
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;

    public class RequestFolder
    {
        private List<RequestFile> _files = new List<RequestFile>();
        private List<RequestFolder> _folders = new List<RequestFolder>();
        private string _name;
        private string _path;

        public RequestFolder(DirectoryInfo info)
        {
            this._path = info.FullName;
            this._name = info.Name;
        }

        public void Load()
        {
            this._folders.Clear();
            this._files.Clear();
            DirectoryInfo info = new DirectoryInfo(this._path);
            foreach (DirectoryInfo info2 in from di in info.GetDirectories()
                orderby di.Name
                select di)
            {
                RequestFolder item = new RequestFolder(info2);
                this._folders.Add(item);
                item.Load();
            }
            foreach (FileInfo info3 in from fi in info.GetFiles("*.xml")
                orderby fi.Name
                select fi)
            {
                RequestFile file = new RequestFile(info3);
                this._files.Add(file);
            }
        }

        public List<RequestFolder> Folders
        {
            get
            {
                return this._folders;
            }
        }

        public string Name
        {
            get
            {
                return this._name;
            }
        }

        public string Path
        {
            get
            {
                return this._path;
            }
        }

        public List<RequestFile> Requests
        {
            get
            {
                return this._files;
            }
        }
    }
}

